<?php namespace Admin\Controller;

     use Common\Model\Attr;
//	 类型属性控制器
	class AttrController extends CommonController{
	 private $adb;
	 public function __init(){
	 	$this->adb=new Attr;
		parent::__init();
	 }
	 public function index(){
	 	$tid=Q('get.tid',0,'intval');
		$data=$this->adb->where('tid',$tid)->get();
		
//		var_dump($tid);die;
        View::with('tid',$tid);
        View::with('data',$data);
		
	 	View::make();
	 }
	 public function add(){

	 	if(IS_POST){

		$result=$this->adb->store();
		if(!$result){
		   View::error($this->db->getError());
		}
			View::success('添加成功',U('Type/index'));
		}
       
	 	$tid=Q('get.tid',0,'intval');
        View::with('tid',$tid);
	 	View::make();
	 }
	 public function edit(){
	 	$taid=Q('get.taid',0,'intval');
//      var_dump($taid);die;
        $tData=$this->adb->where('taid',$taid)->find();
//		var_dump($tData);die;
		View::with('tData',$tData); 	
	 	View::make();
	 }
	public function del(){
		$taid=Q('get.taid',0,'intval');
//		var_dump($taid);die;
		$this->adb->where('taid',$taid)->delete();
		View::success('删除成功',U('Attr/index'));

	}
	}	
	
	
	
	
	
	
	
	
	
	
	
	
	
	?>